package com.welsmann.app.start.spider.service;

import java.text.SimpleDateFormat;

import com.welsmann.app.start.spider.common.SpiderUtil;
import com.welsmann.app.start.spider.dao.SimpleAirQualityDAO;
import com.welsmann.app.start.spider.entity.SimpleAirQuality;

public class WeatherService {
	
	private static SimpleDateFormat sdf = new SimpleDateFormat(
			"yyyy-MM-dd HH:mm:ss");
	
	public static SimpleAirQuality getLatest() {
		return SimpleAirQualityDAO.latest();
	}
	
	public static void saveSimpleAirQuality(SimpleAirQuality saq) {
		SimpleAirQuality latest = SimpleAirQualityDAO.latest();
		if (latest != null && latest.getPublish().equals(saq.getPublish())) {
			return;
		}
		saq.setId(SpiderUtil.uuid());
		SimpleAirQualityDAO.insert(saq);
	}
}
